package com.he.mementomodel.originator;

import com.he.mementomodel.memento.ApplyMemento;

import java.util.Date;

/**
 * 原始类，也就是需要备份的类，可以创建备份，也可以恢复备份
 */
public class OriginatorApply {

    private String applyId;

    private String applyCode;

    private Date ctime;

    private String ownerName;

    private String auditName;


    /**
     * 创建备份
     * @return
     */
    public ApplyMemento createMemento() {
        return new ApplyMemento(applyId,applyCode,ctime,ownerName,auditName);
    }

    /**
     * 回复备份
     * @param applyMemento
     */
    public void restoreMemento(ApplyMemento applyMemento) {
        applyId = applyMemento.getApplyId();
        applyCode = applyMemento.getApplyCode();
        ctime = applyMemento.getCtime();
        ownerName = applyMemento.getOwnerName();
        auditName = applyMemento.getAuditName();
    }

    public String getApplyId() {
        return applyId;
    }

    public void setApplyId(String applyId) {
        this.applyId = applyId;
    }

    public String getApplyCode() {
        return applyCode;
    }

    public void setApplyCode(String applyCode) {
        this.applyCode = applyCode;
    }

    public Date getCtime() {
        return ctime;
    }

    public void setCtime(Date ctime) {
        this.ctime = ctime;
    }

    public String getOwnerName() {
        return ownerName;
    }

    public void setOwnerName(String ownerName) {
        this.ownerName = ownerName;
    }

    public String getAuditName() {
        return auditName;
    }

    public void setAuditName(String auditName) {
        this.auditName = auditName;
    }

    public void init() {
        applyId = "absad2123";
        applyCode = "1001";
        ctime = new Date();
        ownerName = "zs";
        auditName = "ls";

    }

    @Override
    public String toString() {
        return "OriginatorApply{" +
                "applyId='" + applyId + '\'' +
                ", applyCode='" + applyCode + '\'' +
                ", ctime=" + ctime +
                ", ownerName='" + ownerName + '\'' +
                ", auditName='" + auditName + '\'' +
                '}';
    }
}
